﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TestImpresion.Controles
{
    public partial class EncuadernadoDynamicArillo : UserControl
    {
        private readonly DependencyProperty _solapa1Property =
DependencyProperty.Register("SolapaUno", typeof(double), typeof(EncuadernadoDynamicArillo), new PropertyMetadata(new Double()));

        [System.ComponentModel.Category("User properties")]
        [System.ComponentModel.Description("User SolapaUno")]
        public double SolapaUno
        {
            get { return (double)GetValue(_solapa1Property); }
            set
            {
                SetValue(_solapa1Property, value);
            }
        }

        private readonly DependencyProperty _solapa2Property =
DependencyProperty.Register("SolapaDos", typeof(double), typeof(EncuadernadoDynamicArillo), new PropertyMetadata(new Double()));

        [System.ComponentModel.Category("User properties")]
        [System.ComponentModel.Description("User SolapaDos")]
        public double SolapaDos
        {
            get { return (double)GetValue(_solapa2Property); }
            set
            {
                SetValue(_solapa2Property, value);
            }
        }

        private readonly DependencyProperty _voladoProperty =
DependencyProperty.Register("Volado", typeof(double), typeof(EncuadernadoDynamicArillo), new PropertyMetadata(new Double()));

        [System.ComponentModel.Category("User properties")]
        [System.ComponentModel.Description("User Volado")]
        public double Volado
        {
            get { return (double)GetValue(_voladoProperty); }
            set
            {
                SetValue(_voladoProperty, value);
            }
        }

        private readonly DependencyProperty _isArrilloMetalicoProperty =
DependencyProperty.Register("IsArilloMetalico", typeof(bool), typeof(EncuadernadoDynamicArillo), new PropertyMetadata(new Boolean()));

        [System.ComponentModel.Category("User properties")]
        [System.ComponentModel.Description("User IsArilloMetalico")]
        public bool IsArilloMetalico
        {
            get { return (bool)GetValue(_isArrilloMetalicoProperty); }
            set
            {
                SetValue(_isArrilloMetalicoProperty, value);
            }
        }

        public EncuadernadoDynamicArillo()
        {
            InitializeComponent();
            this.rdbMetalico.IsChecked = true;
        }

        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            var radio = (RadioButton) sender;
            this.IsArilloMetalico = radio.Name == "rdbMetalico";
        }

        private void BtnUp_OnClick(object sender, RoutedEventArgs e)
        {
            double insertos;
            var esnumero = double.TryParse(this.txtSolapa1.Text, out insertos);
            this.txtSolapa1.Text = esnumero ? (insertos + 1).ToString() : "0";
        }

        private void Btndown_OnClick(object sender, RoutedEventArgs e)
        {
            double insertos;
            var esnumero = double.TryParse(this.txtSolapa1.Text, out insertos);
            this.txtSolapa1.Text = esnumero && insertos > 0 ? (insertos - 1).ToString() : "0";
        }

        private void BtnUp2a_OnClick(object sender, RoutedEventArgs e)
        {
            double insertos;
            var esnumero = double.TryParse(this.txtSolapa2.Text, out insertos);
            this.txtSolapa2.Text = esnumero ? (insertos + 1).ToString() : "0";
        }

        private void Btndown2a_OnClick(object sender, RoutedEventArgs e)
        {
            double insertos;
            var esnumero = double.TryParse(this.txtSolapa2.Text, out insertos);
            this.txtSolapa2.Text = esnumero && insertos > 0 ? (insertos - 1).ToString() : "0";
        }

        private void BtnUpvolado_OnClick(object sender, RoutedEventArgs e)
        {
            double insertos;
            var esnumero = double.TryParse(this.textBoxvolado.Text, out insertos);
            this.textBoxvolado.Text = esnumero ? (insertos + 1).ToString() : "0";
        }

        private void Btndownvolado_OnClick(object sender, RoutedEventArgs e)
        {
            double insertos;
            var esnumero = double.TryParse(this.textBoxvolado.Text, out insertos);
            this.textBoxvolado.Text = esnumero && insertos > 0 ? (insertos - 1).ToString() : "0";
        }
    }
}
